﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
            
           


        } 

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();
            form2.Show();
        }
        public static Dictionary<string, string> users = new Dictionary<string, string>();
        private void button2_Click(object sender, EventArgs e)
        {
            string Name = textBox1.Text.Trim();
            string Pwd = textBox2.Text;

            SqlConnection con = new SqlConnection("server=.;database=Blogs;uid=night;pwd=1147221226");
            con.Open();
            SqlCommand com=new SqlCommand("select * from Users where Username='" + Name + "' and Password='" + Pwd+ "'",con);
            SqlDataAdapter da = new SqlDataAdapter(com);
            DataSet ds = new DataSet();
            int n = da.Fill(ds, "Users");
            if (n!=0)
            {
                MessageBox.Show("登录成功" ,"提示");
                Form3 form3 = new Form3();
                form3.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("账号或者密码错误","提示");
            }
            con.Close();
        }
    }
}
